package com.wd.buycar.view.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.wd.buycar.R

/**
 * 作者：马海钊
 * 时间：2023/9/11 17:23
 * 功能：
 */
class BuynewcarwaineiAdapterList(var context: Context, var list: List<String>) :
    RecyclerView.Adapter<BuynewcarwaineiAdapterList.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view =
            LayoutInflater.from(context).inflate(R.layout.buy_newcar_details_wainei_xiao, parent, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        Glide.with(context)
            .load(list[position])
            .placeholder(R.mipmap.buy_oldcar1)
            .error(R.mipmap.ic_launcher)
            .into(holder.imgid)
    }

    override fun getItemCount(): Int {
        return list.size
    }

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var imgid: ImageView

        init {
            imgid = itemView.findViewById(R.id.buy_newcar_details_wainei_xiao_imgid)
        }
    }
}